#include<iostream>
#include<fstream>
#include<string>

using Str=std::string;

bool copyFile(Str src,Str dst){
    std::ifstream Src(src,std::ios::in);
    std::ofstream Dst(dst,std::ios::trunc);
    char temp;
    if(Src){
        if(!Dst){
            std::cerr<<"Error destination file : "<<src<<" is not open";
            return false;
        }
        Src>>std::noskipws; // don't skip space
        while(Src.good()){
            Src>>temp;
            if(Src.eof())break;
            Dst<<temp;
        }
        Src.close();Dst.close();
        return true;
    }else if(!Dst){

    }else{
        Src.close();Dst.close();
        std::cerr<<"Error source file : "<<src<<" is not open";
        return false;
    }
}
int main(int argc,char**argv){
    Str files[2];int fs=argc;
    switch(argc){
        case 1:
            std::cout<<"please input the source file : ";
            std::cin>>files[0];
        case 2:
            std::cout<<"pleas input the destination file : ";
            std::cin>>files[1];
        case 3:
            while(fs-->1){
                files[fs-1]=argv[fs];
            }
            return !copyFile(files[0],files[1]);
        default:
            std::cerr<<"parameters is over 3";
            return -1;
    }
}
